package com.xiaochong.tir.apiservice.component;

import akka.actor.UntypedActor;
import com.alibaba.fastjson.JSON;
import com.xc.logclient.utils.LogTrace;
import com.xiaochong.tir.apiservice.util.SpringContextUtil;
import com.xiaochong.tir.common.data.hbasepo.CmcCurrencyInfo;
import com.xiaochong.tir.common.data.hbasepo.CoinRank;
import com.xiaochong.tir.common.data.hbasepo.IndustryIndex;
import com.xiaochong.tir.common.data.hbasepo.WeightIndex;
import com.xiaochong.tir.common.util.LogTraceKeysUtils;

import java.util.List;

/**
 * Created by wujiaxing on 2018/5/7.
 */
public class AkkaCoinRank extends UntypedActor {


    private CmcDataCalculateComponent cmcDataCalculateComponent =
            (CmcDataCalculateComponent) SpringContextUtil.getBean("cmcDataCalculateComponent");

    @Override
    public void onReceive(Object o) {
        LogTrace.beginTrace("排行榜计算");
        Object o1 = ((Object[]) o)[0];
        List<CmcCurrencyInfo> cmcCurrencyInfos = (List<CmcCurrencyInfo>) o1;
        LogTrace.info(LogTraceKeysUtils.AKKA_COIN_RANK_TITLE, LogTraceKeysUtils.DATA,"排行榜计算开始");
        try{
            cmcDataCalculateComponent.calculateCoinRank(cmcCurrencyInfos);
        }catch (Exception e){
            e.printStackTrace();
            LogTrace.error(e.getMessage(), e);
        }
        LogTrace.info(LogTraceKeysUtils.AKKA_COIN_RANK_TITLE, LogTraceKeysUtils.DATA,"排行榜计算完成");
        LogTrace.endTrace();
    }
}
